/* Tile.cs

	Infinite Rogue
	By Dan Alexander, Andy Law
	July 2012

	Cross platform roguelike using C#, Mono, WinForms and GDI.
	
	LICENSE: New BSD License
*/

using System;
using System.IO;
using System.Drawing;

public class Tile : TileData
{
    public enum DoorState
    {
        NotDoor, Open, Closed, Locked
    }

	bool _passable;
	DoorState _doorState = DoorState.NotDoor;
	
	//default to floor
	public Tile() {
		Character = '.';
		Color = Color.Gray;
		Passable = true;
		Discovered = false;
		Tag = Utilities.NextTag();
		Description = "empty floor";
	}
	
	//create a tile with <character> and <passable> in the default color
	public Tile(Char character, bool passable){
		Character = character;
		Color = Color.Gray;
		Passable = passable;
		Discovered = false;
		Tag = Utilities.NextTag();
	}

    public bool Passable
    {
        get { return _passable; }
        set { _passable = value; }
    }

    public DoorState DoorStatus
    {
        get { return _doorState;}
        set { _doorState = value; }
    }
	
	public bool OpenDoor(){
        switch (DoorStatus)
        {
            case DoorState.NotDoor:
            case DoorState.Open:
                return true;

            case DoorState.Closed:
                DoorStatus = DoorState.Open;
                Type = TileType.OpenDoor;
                Character = '-';
                Passable = true;
                return true;

            case DoorState.Locked:
            default:
                return false;
        }
	}
} //end of Tile

public class TileData : Printable {
	public bool Discovered { get; set; }
	public TileType Type { get; set; }
	public ulong Tag { get; set; } 
	public string Description { get; set; }
}

public enum TileType
{
	Floor, Wall, OpenDoor, ClosedDoor, Player, Monster, StairDown, StairUp, Item
}